﻿using ControleRepresentante.Data.Catalogs;
using ControleRepresentante.Data.Helpers;

namespace ControleRepresentante.Data.CatalogSteps
{
    class AddColumnIdToBuiltInIndexColumnPreference : CatalogStepBase<ControleRepresentanteCatalogStepTypes>
    {
        protected override ControleRepresentanteCatalogStepTypes CatalogStepType
        {
            get { return ControleRepresentanteCatalogStepTypes.AddColumnIdToBuiltInIndexColumnPreference; }
        }

        public override void Execute(IDataAccess dataAccess)
        {
            dataAccess.ExecuteCommand("DELETE FROM AttributeIndexColumnPreference");
            dataAccess.ExecuteCommand("DELETE FROM BuiltInIndexColumnPreference");
            dataAccess.ExecuteCommand("DELETE FROM IndexColumnsPreference");

            new CatalogStepHelper(dataAccess)
                .GetTable("BuiltInIndexColumnPreference")
                .AddColumn("ColumnId", ColumnType.Guid, false, false);
        }
    }
}
